﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Teamboard.Helpers
{
    using System.Diagnostics;
    using AutoMapper;

    /// <summary>
    /// Object mapper class
    /// </summary>
    public static class ObjectMapper
    {
        static ObjectMapper()
        {
            AddProfile(new Mappings());
        }

        /// <summary>
        /// Adds the specified mapping profile.
        /// </summary>
        /// <param name="profile">The profile to add</param>
        public static void AddProfile(Profile profile)
        {
            Mapper.AddProfile(profile);
        }

        /// <summary>
        /// Maps the specified source.
        /// </summary>
        /// <typeparam name="TSource">The type of the source.</typeparam>
        /// <typeparam name="TDestination">The type of the destination.</typeparam>
        /// <param name="source">The source.</param>
        /// <returns>Mapped object of type TDestination</returns>
        [DebuggerStepThrough]
        public static TDestination Map<TSource, TDestination>(this TSource source) where TSource : class
        {
            return Mapper.Map<TSource, TDestination>(source);
        }

        /// <summary>
        /// Maps the specified source to destination
        /// </summary>
        /// <typeparam name="TSource">The type of the source.</typeparam>
        /// <typeparam name="TDestination">The type of the destination.</typeparam>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <returns>Mapped object of type TDestination</returns>
        [DebuggerStepThrough]
        public static TDestination Map<TSource, TDestination>(this TSource source, TDestination target) where TSource : class
        {
            return Mapper.Map(source, target);
        }
    }
}